import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import axios from 'axios'
import eIconPicker from 'e-icon-picker'
import 'e-icon-picker/lib/symbol.js' // 基本彩色图标库
import 'e-icon-picker/lib/index.css' // 基本样式，包含基本图标
import 'font-awesome/css/font-awesome.min.css' // font-awesome 图标库
import 'element-ui/lib/theme-chalk/icon.css' // element-ui 图标库

// 全局删除增加图标
Vue.use(eIconPicker, {
  FontAwesome: true,
  ElementUI: true,
  eIcon: true, // 自带的图标，来自阿里妈妈
  eIconSymbol: true, // 是否开启彩色图标
  addIconList: [],
  removeIconList: [],
  zIndex: 3100 // 选择器弹层的最低层,全局配置
})

// 引入 Element
Vue.use(ElementUI)

const imageUrl = 'http://101.43.223.224:8765/image/getImageById'

Vue.prototype.$imageUrl = imageUrl

// 引入 axios
Vue.prototype.$axios = axios
axios.defaults.baseURL = 'http://localhost:8088'
// axios.defaults.baseURL = 'http://101.43.223.224:8088'

axios.interceptors.request.use((config) => {
  config.headers.token = window.sessionStorage.getItem('token')
  return config
})

axios.interceptors.response.use((config) => {
  if (config.data.code === '401') {
    ElementUI.Message(config.data.obj)
    router.push('/')
  }
  return config
})

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
